<template>
  <div class="base-table-box">
    <div class="table-select-group">
      <div class="left">
        <s-select
          :selectOption="year"
          v-model="params.strYear"
          style="width: 100px"
        />
        <s-select
          :selectOption="socialPublic.node"
          v-model="params.strPubNode"
          style="width: 100px"
        />
        <s-select
          :selectOption="socialPublic.selectType"
          v-model="params.strPubType"
          style="width: 100px"
        />
        <a-input
          class="search-input"
          v-model="params.search"
          placeholder="请输入搜索内容"
        />
        <a-button style="margin-left: 16px" type="primary" @click="start"
          >查询</a-button
        >
        <a-button @click="reset" class="btn-reset">重置</a-button>
      </div>
      <div class="right">
        <a-button type="primary">导出</a-button>
      </div>
    </div>
    <div class="advanced-search-group"></div>
    <a-table
      :row-selection="{
        selectedRowKeys: selectedRowKeys,
        onChange: onSelectChange
      }"
      :pagination="pagination"
      :columns="columns"
      :data-source="tableData"
      :loading="loading"
      :scroll="{ y: '100%' }"
    >
      <div slot="action" slot-scope="record">
        <div class="tools">
          <span @click="audit(record.key)">审核</span>
          <span>导出</span>
        </div>
      </div>
      <div slot="state" slot-scope="text">
        <span class="end" v-if="text == '已上报'">{{ text }}</span>
        <span class="start" v-else>{{ text }}</span>
      </div>
    </a-table>
  </div>
</template>
<script>
import paging from 'mixins/paging'
import deleteItem from 'mixins/delete-table-item.js'
import { socialPublic } from 'assets/js/select-option-list'
const columns = [
  {
    title: '信息标题',
    dataIndex: 'title'
  },
  {
    title: '上报人',
    dataIndex: 'person'
  },
  {
    title: '上报类型',
    dataIndex: 'type',
    sorter: (a, b) => a.name.length - b.name.length,
    scopedSlots: { customRender: 'state' }
  },
  {
    title: '提交时间',
    dataIndex: 'time',
    sorter: (a, b) => a.name.length - b.name.length
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]

export default {
  data() {
    return {
      columns,
      socialPublic,
      params: {
        strYear: '2021',
        strPubType: 'all',
        strPubNode: 'all',
        search: ''
      },
      year: [
        { key: '2021', label: '2021' },
        { key: '2020', label: '2020' }
      ]
    }
  },
  mixins: [paging, deleteItem],
  methods: {
    //列表审核跳转
    audit() {
      this.$router.push('/console/socialPublic/message/infoReview/messageAudit')
    },
    start() {
      console.log(this.form)
    },
    reset() {
      this.form = {}
    },
    add() {},
    deleteList(ids) {
      this.deleteItemMixins(() => {}, ids)
    },
    getTableData() {
      for (let i = 0; i < this.pagination.pageSize; i++) {
        this.tableData.push({
          key: i,
          title: `Edward King ${i}`,
          person: '张三',
          time: `20210303`,
          type: Math.round(Math.random()) > 0.5 ? '已上报' : '未上报'
        })
      }
      this.pagination.total = 200
    }
  }
}
</script>
<style lang="less" scoped>
.tools span:last-child {
  margin: 0 0 0 15px;
}
.tools span {
  color: #1c8de8;
  cursor: pointer;
  font-size: 16px;
}
.end {
  color: green;
}
.start {
  color: red;
}
</style>